package com.xm.xmapp.adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;

import com.xm.xmapp.R;
import com.xm.xmapp.app.CodeConstant;
import com.xm.xmapp.app.MyAppcation;
import com.xm.xmapp.base.MyBaseAdapter;
import com.xm.xmapp.base.ViewHolder;
import com.xm.xmapp.customview.CustomTextView;
import com.xm.xmapp.customview.CustomTextView.InnerStatus;
import com.xm.xmapp.response.bean.ResponseUserMessageListBean;
import com.xm.xmapp.tools.StringTools;

public class MyAssetAdapter extends MyBaseAdapter<ResponseUserMessageListBean> {

	public MyAssetAdapter(ArrayList<ResponseUserMessageListBean> list,
			Activity activity, int layoutId) {
		super(list, activity, layoutId);
	
	}

	@Override
	public void setValues(ViewHolder holder,
			final ResponseUserMessageListBean t, int position) {
	
		holder.setText(R.id.title, t.user_message_title)
				.setText(R.id.content, StringTools.HtmlText(t.user_message_content))
				.setText(R.id.time, t.modified_on);

		final CustomTextView text = (CustomTextView) holder.getView(R.id.title);

		if (MyAppcation.getMyAppcation().queryData(
				CodeConstant.User_message, CodeConstant.User_message_id,
				t.user_message_id+MyAppcation.getMyAppcation().getUid())) {
			text.setVisibility(InnerStatus.GONE);
		} else {
			text.setVisibility(InnerStatus.VISIBLE);
		}

		holder.getConvertView().setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				MyAppcation.getMyAppcation().insertData(
						CodeConstant.User_message,
						CodeConstant.User_message_id, t.user_message_id+MyAppcation.getMyAppcation().getUid());
				text.setVisibility(InnerStatus.GONE);
				if(in!=null)
				{
					in.DoSomeThing(t);
				
					
				}

			
			}
		});
	}

}
